<template>
    <div class="swiper-container" ref="loop">
        <div class="swiper-wrapper">
            <!-- 默认分发位置 -->
            <slot></slot>
        </div>

        <!-- 具名slot -->

        <!-- 如果需要分页器 -->
        <slot name="pagination" class="swiper-pagination"></slot>
        <!-- 如果需要导航按钮 -->
        <slot name="prev" class="swiper-button-prev"></slot>
        <slot name="next" class="swiper-button-next"></slot>
        <!-- 如果需要滚动条 -->
        <slot name="scrollbar" class="swiper-scrollbar"></slot>
    </div>
</template>

<script>
import Swiper from 'swiper';
export default {
    props:{
        options:{
            type:Object,
            default(){
                return {};
            }
        },
        loops:{
            type:Array,
            dafault(){
                return [];
            }
        }
    },
    watch:{
        loops(){
            this.$nextTick(()=>{
                this.$swiper.update() 
            })
        }
    },
    methods: {
        initSwiper(){
            this.$nextTick(()=>{
                this.$swiper = new Swiper(this.$refs.loop,this.options);
            })
        }
    },
    mounted() {
        this.initSwiper();
    },
}
</script>